package com.wx.spring.boot.dubbo.controller;

import com.wx.boot.dubbo.api.service.UserService;
import com.wx.boot.dubbo.api.vo.UserVO;
import org.apache.dubbo.config.annotation.Method;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName TestController
 * @Author wx
 * @Description 测试
 * @Date 2019-04-13-18:26
 */
@RestController
public class TestController {
    
    /**
     * 接口除getUserAllList以外的方法，最长请求时间为5秒，getUserAllList方法请求时间为1秒,如果超时并重试3次，第一次访问不算，一共4次
     */
    @Reference(timeout = 5000,methods = {@Method(name = "getUserAllList",timeout = 1000,retries = 3)})
    private UserService userService;

    @GetMapping("getUsetListAll")
    public List<UserVO> getUsetListAll(){
        System.out.println("服务消费方重试");
        return  userService.getUserAllList();
    }
    @GetMapping("getUserTest")
    public List<UserVO> getUserTest(){
        return  userService.getUserTest();
    }
}
